package cn.edu.imau.zy.examination.controller;



import cn.edu.imau.zy.examination.domain.ElExam;
//import cn.edu.imau.zy.examination.domain.ElExamRepo;
//import cn.edu.imau.zy.examination.service.IElExamRepoService;
import cn.edu.imau.zy.examination.service.IElExamService;
//import cn.edu.imau.zy.examination.service.IElPaperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.edu.imau.zy.common.annotation.LoginUser;
import cn.edu.imau.zy.common.core.entity.system.SysUser;


import cn.edu.imau.zy.common.core.domain.R;
import cn.edu.imau.zy.common.core.controller.BaseController;


/**
 * 课程 提供者
 * 
 * @author xsc
 * @date 2021-07-28
 */
@RestController
@RequestMapping("exam")
public class ElExamController extends BaseController
{
	
	@Autowired
	private IElExamService elExamService;

//	@Autowired
//	private IElExamRepoService elExamRepoService;

	
	/**
	 * 查询${tableComment}
	 */
	@GetMapping("get/{id}")
	public ElExam get(@PathVariable("id") String id)
	{
		return elExamService.getById(id);
		
	}

//	@GetMapping("repo/{id}")
//	public R getRepo(@PathVariable("id") String id){
//		return R.data(elExamRepoService.getById(id));
//	}

	
	/**
	 * 查询课程列表
	 */
	@GetMapping("list")
	public R list(ElExam elExam)
	{
		startPage();
        return result(elExamService.queryList(elExam));
	}
	
	
	/**
	 * 新增保存课程
	 */
	@PostMapping("save")
	public R addSave(@RequestBody ElExam elExam,@LoginUser SysUser sysUser)
	{
		System.out.println("-----------------");
		System.out.println(sysUser);
		System.out.println("--------------------");
		return toAjax(elExamService.elSave(elExam));
	}

	/**
	 * 修改保存课程
	 */
	@PostMapping("update")
	public R editSave(@RequestBody ElExam elExam,@LoginUser SysUser user)
	{
//		elExam.setUpdateBy(user.getUserId().toString());
		return toAjax(elExamService.updateById(elExam));
	}
	
	/**
	 * 删除${tableComment}
	 */
	@PostMapping("remove")
	public R remove(String ids)
	{		
		return toAjax(elExamService.removeById(ids));
	}
	
}
